//
//  HttpConnectionUtil.h
//  Surfing_Platform
//
//  Created by amei on 12-4-30.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
@protocol HttpConnectionDelegate;

static int HTTP_REQUEST_GET = 0;
static int HTTP_REQUEST_POST = 1;

@interface HttpConnectionUtil : NSObject{
@private
    NSURLConnection *mConnection;
    NSMutableData   *mReceiveData;
    NSString        *mResponseData;
    
    id<HttpConnectionDelegate> mDelegate;
}
@property(nonatomic, retain) NSURLConnection *mConnection;
@property(nonatomic, retain) NSMutableData *mReceiveData;
@property(nonatomic, retain) NSString   *mResponseData;
@property(nonatomic, assign) id<HttpConnectionDelegate> mDelegate;

-(BOOL)connectedToNetwork:(NSString*) url;
-(BOOL)NetworkAvisible;
-(id)initWithDelegate:(id <HttpConnectionDelegate>)delegate;
-(void)asyncConnect:(NSString *)url AndMethod:(int) method MutableData:(NSMutableData*) data;
-(void)syncConnect:(NSString *)url AndMethod:(int) method MutableData:(NSMutableData*) data;
@end

@protocol HttpConnectionDelegate <NSObject>

/*
 response: the content
 response: failed
 response: connection_failed
 */
-(void) ReponseCallBack:(NSString *) response;

@end
